<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Simple Youtube Player</title>
<script type="text/javascript" src="assets/scripts/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="assets/scripts/oauth2.js"></script>
<script type="text/javascript" src="assets/scripts/googleAuthConfig.js"></script>
<script type="text/javascript" src="assets/scripts/YoutubeVideo.js"></script>
</head>
<body>
<script type="text/javascript">
var play_ended = false, videos = [], in_played = 0, played = false, notification;

// 準備拉出playlist內的影片ID
var setPlaylistQueryUri = function (uri) {
  videos = loadVideos(googleAuth, uri);
  for (var i in videos) {
    showVideo();
    break;
  }
}

//var videos = ["iY5YR74xyu4", "TehMVCmcVxU", "Fyk5eXDaDKw"];
//var videos = ["iY5YR74xyu4", "TehMVCmcVxU", "qtLXkgaq6Gk", "MzgpmE_nATc"];



function set_not_played () {
  played = false;
}
function showVideo (dir) {
  var d = dir || true;
  if (in_played > videos.length - 1) {
    in_played = 0;
  }
  if (d == false) { // 逆向播放時
    if (in_played - 1 < 0)  in_played = 0;
    else in_played -= 1;
  }
  if (played === true)  return false;
  if (notification != null) {
    notification.cancel();
  }
  notification = webkitNotifications.createHTMLNotification(
    'player.html?'+videos[in_played]  // html url - can be relative
  );
  notification.show();
  in_played += 1;
  played = true;
}
</script>
</body>
</html>